﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Emulator.Base.CPU;
using Emulator.GameBoyConfig;

namespace Emulator.GameBoy.CPU
{
    public class GameBoyCPUDecoder:CPUDecoderBase
    {
        public GameBoyInstruction Decode(int aOpCode, GameBoyCPU aGBCPU)
        {
            if (aOpCode == 0xCB)
            {
                int mReadByte = aGBCPU.ReadAndMoveForward();
                if (InstructionMapper.MultipleOpCodeConfig.Keys.Contains(mReadByte))
                    return InstructionMapper.MultipleOpCodeConfig[mReadByte];
                else
                    return null;
            }
            else
            {
                if (InstructionMapper.SinglOpCodeConfig.Keys.Contains(aOpCode))
                    return InstructionMapper.SinglOpCodeConfig[aOpCode];
                else
                {
                    return null;
                }
            }
        }
    }
}
